<?php include $this->admin_tpl("header"); ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/haidaoblue/easyui.css">
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/icon.css">
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/locale/easyui-lang-zh_CN.js"></script>
<style type="text/css">
	.menu {background:#FFFFFF;}
	#batch .m-btn-small {margin-left: 0;}
</style>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/hd_default_config.js"></script>
	<!-- 内容区 -->
	<div class="content">
		<div class="site">
			<?php echo C('site_name')?> <a href="#">商品管理</a> > 商品列表
		</div>
		<span class="line_white"></span>
	<div class="goods mt10">
		<div class="guanli">
			<span style="margin-right: 10px;">按分类查看</span>
			<select name='category_id' id='category_id' class="easyui-combobox" data-options="editable:false" style="height: 26px;">
			</select>
			<span style="margin-right: 10px;margin-left: 5px;">搜索</span>
			<input id="keyword" class="easyui-textbox" name="keyword" style="width:210px;height: 26px;" prompt="输入商品名称">
			<a id="search" href="#" class="easyui-linkbutton" style="height: 26px;padding-right: 10px;">查询</a>
		</div>
	<dl class="mt10">
		<dt><p>
			<a href="<?php echo U('lists');?>" <?php if($_GET['label'] == ''){?>class="hover"<?php } ?> >全部商品</a>
		
		</dt>
		<dd>
			<div class="login mt10" style="border: none;">
				<table id="order_list_grid" style="width:100%"></table> 
			</div>
			<div id="mm1" class="easyui-menu" style="width:90px!important;">
					<div>恢复商品</div>
					<div>销毁商品</div>
					<div>设为促销</div>
					<div>设为热卖</div>
					<div>设为新品</div>
					<div>取消促销</div>
					<div>取消热卖</div>
					<div>取消新品</div>
					<div>商品上架</div>
					<div>商品下架</div>
			 </div>
			<div class="clear"></div>
		</dd>
	</dl>
		 <?php include $this->admin_tpl('copyright') ?>
	</div>
<!-- /内容区 -->
	<script type="text/javascript">
		$(function(){
			//默认高亮
			$(window.parent.document).find(".z_side").removeClass("hover");
			$(window.parent.document).find(".n10").addClass("hover");
		})
	</script>
	<!--表格js-->
	<script type="text/javascript">
	var dom = $('#member_list');
	var pageSize = <?php echo PAGE_SIZE?>;//每页显示数量
	//会员增删改查
	var dataurl = '<?php echo U('lists')?>';
	var addurl = '<?php echo U('add')?>';
	var delurl = '<?php echo U('delete')?>';
	var editurl = '<?php echo U('edit')?>';


	var addressurl = '<?php echo U('MemberAddress/lists')?>';
	var rebateurl = '<?php echo U('Memberrebate/lists')?>';
	var sellrebateurl = '<?php echo U('Memberrebate/selllists')?>';
	var orderurl = '<?php echo U('Goods/AdminOrder/lists')?>';
	
	var renzheng = '<?php echo U('renzhegn_check') ?>';
	var repasswordurl = '<?php echo U('repassword')?>';
	var repinpassurl = '<?php echo U('repinpass')?>';
	// var setpotionsurl = '<?php echo U('setpoints')?>';
	$(function(){
		//js创建数据表格
		var memlist = dom.datagrid({
			url:dataurl,//从远程站点请求数据的 URL
			striped:true,//true 把行条纹化。（即奇偶行使用不同背景色）
			width:'100%',
			title:"统计概览",  
			fitColumns:true,//会自动扩大或缩小列的尺寸以适应网格的宽度并且防止水平滚动
			checkOnSelect:true,//true，当用户点击某一行时，则会选中/取消选中复选框。
			//如果设置为 false 时，只有当用户点击了复选框时，才会选中/取消选中复选框。
			toolbar:[
				{
					id:'addrow',
					text:'添加',
					iconCls:'icon-add',
				},'-'
			],
			frozenColumns:[[
				{field:'id',checkbox:true}
			]],
			pagination:true,
			pageSize:pageSize,
			pageList: [pageSize,pageSize*2,pageSize*4],//可以设置每页记录条数的列表
			frozenColumns:[[
				{field:'id',title:'ID',fixed:true,align:'center',width:'5%'},
				
				//没有定义宽度将会降低性能	
			]],	
			{field:'name',title:'商品名称',halign:'center',align:'center',width:'10%',sortable:true},
			{field:'category_name',title:'所属分类',halign:'center',align:'center',width:'10%',sortable:true},
			{field:'price',title:'价格GF',halign:'center',align:'center',width:'4%',sortable:true},
			{field:'status',title:'状态',halign:'center',align:'center',width:'4%',sortable:true,
				formatter:function(value,row,index){
					if(value==1){
						return "已上架";
					}else if(value == 0){
						return "<span class=red>已下架</span>";
					}
				}
				
			},
				
						
				
				{field:'add_time',title:'添加时间',width:'10%',align:'center',sortable:false},

				{field:'userID',title:'操作',width:'28%',align:'center',halign:'center',
					formatter:function(value,row,index){
						// var sp_txt="&nbsp;&nbsp;&nbsp;&nbsp;";

						return
								'<a  href="'+editurl+'&id='+row.id+'&if_upd=1">编辑</a>';
							
					}
				},
			]],
			onLoadSuccess:function(data){
				// $(".panel-title").eq(0).html(data.title);
				
				
				var category_id = data.category_id;
				category_id.unshift({"id":"","name":"请选择"})
				$('#complete_combbox').combobox({
					data:category_id,
					valueField:'id',
					textField:'name'
				});
			}
		});
		//回车查询
		$('#keyword').textbox('textbox').bind('keydown',function (e) {
			if (e.keyCode == 13) {
				$('#search').trigger('click');
			}
		});
		//增加查询参数，重新加载表格
		$('#search').bind('click',function (){
			var queryParams = dom.datagrid('options').queryParams;
			queryParams.start = $('#start').datebox('getValue');
			queryParams.end = $('#end').datebox('getValue');
			queryParams.keyword = $("#keyword").val();
			// queryParams.user_type = $('#group_combbox').combobox('getValue');
			queryParams.status = $('#ban_combbox').combobox('getValue');
			queryParams.if_identification = $('#renzheng_combbox').combobox('getValue');
			queryParams.if_complete = $('#complete_combbox').combobox('getValue');
			dom.datagrid('options').queryParams = queryParams;
			dom.datagrid('reload');
		})
		//添加会员
		$('#addrow').bind('click',function(){
			window.location.href=addurl;
		})
		//删除操作
		$('#delrows').bind('click', function(){
			$.messager.alert('警告','请不要进行删除操作！');
			return false;

			var ids = [];
			var rows = dom.datagrid('getChecked');
			for(var i=0; i<rows.length; i++){
				ids.push(rows[i].id);
			}
			if (ids.length > 0){
				$.messager.confirm('确认','您确认想要删除记录吗？',function(r){
					if (r){
						$.getJSON(delurl,
						{"id[]":ids},
						function(data){
							if(1 == data.status){// 删除成功，则需要在树中删除节点
								// 检修任务grid 执行load
								dom.datagrid("reload");  //重新加载
							}else{
								$.messager.alert('警告',data.info);
							}
						})
					}else{
						dom.datagrid('clearSelections').datagrid('clearChecked');
					}
				});
			}else{
				$.messager.alert('警告','请选择要删除的记录');
				return false;
			}
		});
	});
	//积分弹窗
	function pay_points(value,index){
		$('input[name="user_id"]').val(value);
		$('#poinospanel').window('open');
	}
	//经验
	function exp(value,index){
		$('input[name="user_id"]').val(value);
		$('#exppanel').window('open');
	}
	// 余额
	function user_money(value,index) {
		$('input[name="user_id"]').val(value);
		$('#moneypanel').window('open');
	}
</script>